home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sources.misc
- From: Leonid A. Broukhis <leo@s514.ipmce.su>
- Subject: v19i087: freeze - Freeze/Melt compression package, Patch02
- Message-ID: <1991May17.201119.367@sparky.IMD.Sterling.COM>
- X-Md4-Signature: 19aff6932dedabad7696155095a6ab73
- Date: Fri, 17 May 1991 20:11:19 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: Leonid A. Broukhis <leo@s514.ipmce.su>
- Posting-number: Volume 19, Issue 87
- Archive-name: freeze/patch02
- Patch-To: freeze: Volume 17, Issue 67-68
-
- *** ../distribution/bitio.c Wed Mar 27 19:44:42 1991
- --- bitio.c Mon May 6 21:52:47 1991
- ***************
- *** 76,82 ****
- register u_short b = putbuf;
- b |= c >> len;
- if ((len += l) >= 8) {
- ! if (putchar ((int)(b >> 8)) == EOF) writeerr();
- if ((len -= 8) >= 8) {
- putchar ((int)b);
- bytes_out += 2;
- --- 76,82 ----
- register u_short b = putbuf;
- b |= c >> len;
- if ((len += l) >= 8) {
- ! putchar ((int)(b >> 8));
- if ((len -= 8) >= 8) {
- putchar ((int)b);
- bytes_out += 2;
- ***************
- *** 87,92 ****
- --- 87,94 ----
- bytes_out++;
- }
- }
- + if (ferror(stdout))
- + writeerr();
- putbuf = b;
- putlen = len;
- }
- *** ../distribution/decode.c Wed Mar 27 19:45:02 1991
- --- decode.c Mon May 13 15:23:12 1991
- ***************
- *** 52,58 ****
- }
-
- if (!quiet && (in_count > indicator_count)) {
- ! fprintf(stderr, "%5dK\b\b\b\b\b\b", in_count / 1024);
- fflush (stderr);
- indicator_count += indicator_threshold;
- indicator_threshold += 1024;
- --- 52,60 ----
- }
-
- if (!quiet && (in_count > indicator_count)) {
- ! if (ferror(stdout))
- ! writeerr();
- ! fprintf(stderr, "%5ldK\b\b\b\b\b\b", in_count / 1024);
- fflush (stderr);
- indicator_count += indicator_threshold;
- indicator_threshold += 1024;
- *** ../distribution/encode.c Mon May 13 15:12:04 1991
- --- encode.c Sun May 12 14:15:03 1991
- ***************
- *** 113,119 ****
-
- in_count += i;
- if ((in_count > indicator_count) && !quiet) {
- ! fprintf(stderr, "%5dK\b\b\b\b\b\b", in_count / 1024);
- fflush (stderr);
- indicator_count += indicator_threshold;
- indicator_threshold += 1024;
- --- 113,119 ----
-
- in_count += i;
- if ((in_count > indicator_count) && !quiet) {
- ! fprintf(stderr, "%5ldK\b\b\b\b\b\b", in_count / 1024);
- fflush (stderr);
- indicator_count += indicator_threshold;
- indicator_threshold += 1024;
- *** ../distribution/freeze.c Mon May 13 15:12:07 1991
- --- freeze.c Mon May 13 15:15:31 1991
- ***************
- *** 33,39 ****
- uchar magic_header[] = { "\037\237" }; /* 1F 9F = freeze 1.X + 1 */
- #endif
-
- ! static char ident[] = "@(#) freeze.c 2.2.%d Alpha 3/27/91 leo@s514.ipmce.su\n";
-
- #define ARGVAL() (*++(*argv) || (--argc && *++argv))
-
- --- 33,39 ----
- uchar magic_header[] = { "\037\237" }; /* 1F 9F = freeze 1.X + 1 */
- #endif
-
- ! static char ident[] = "@(#) freeze.c 2.2.%d Alpha 5/13/91 leo@s514.ipmce.su\n";
-
- #define ARGVAL() (*++(*argv) || (--argc && *++argv))
-
- ***************
- *** 43,49 ****
- #ifdef DEBUG
-
- # ifdef MSDOS
- ! fprintf(stderr,"Usage: freeze [-cdDfivV] [file | +type ...]\n");
- # else
- fprintf(stderr,"Usage: freeze [-cdDfvV] [file | +type ...]\n");
- # endif /* MSDOS */
- --- 43,49 ----
- #ifdef DEBUG
-
- # ifdef MSDOS
- ! fprintf(stderr,"Usage: freeze [-cdDfitvV] [file | +type ...]\n");
- # else
- fprintf(stderr,"Usage: freeze [-cdDfvV] [file | +type ...]\n");
- # endif /* MSDOS */
- ***************
- *** 51,57 ****
- #else
-
- # ifdef MSDOS
- ! fprintf(stderr,"Usage: freeze [-cdfivV] [file | +type ...]\n");
- # else
- fprintf(stderr,"Usage: freeze [-cdfvV] [file | +type ...]\n");
- # endif /* MSDOS */
- --- 51,57 ----
- #else
-
- # ifdef MSDOS
- ! fprintf(stderr,"Usage: freeze [-cdfitvV] [file | +type ...]\n");
- # else
- fprintf(stderr,"Usage: freeze [-cdfvV] [file | +type ...]\n");
- # endif /* MSDOS */
- ***************
- *** 71,81 ****
- char ofname [100];
-
- #ifdef MSDOS
- ! # define PATH_SEP '\\'
- ! short image = 2; /* 1 <=> image (binary) mode; 2 <=> text mode */
- #else
- char deffile[] = "/etc/default/freeze";
- - # define PATH_SEP '/'
- #endif
-
- #ifdef DEBUG
- --- 71,85 ----
- char ofname [100];
-
- #ifdef MSDOS
- ! char *last_sep(); /* last slash, backslash, or colon */
- ! # ifdef BIN_DEFAULT
- ! short image = O_BINARY;
- ! # else
- ! short image = O_TEXT;
- ! # endif
- #else
- + # define last_sep(s) rindex((s), '/') /* Unix always uses slashes */
- char deffile[] = "/etc/default/freeze";
- #endif
-
- #ifdef DEBUG
- ***************
- *** 116,122 ****
- * conversion between UNIX text representation (LF line
- * termination) in frozen form and MS-DOS text
- * representation (CR-LF line termination) in melted
- ! * form. Useful with non-text files.
- *
- * -v: Write freezing statistics
- *
- --- 120,133 ----
- * conversion between UNIX text representation (LF line
- * termination) in frozen form and MS-DOS text
- * representation (CR-LF line termination) in melted
- ! * form. Useful with non-text files. Default if
- ! * BIN_DEFAULT specified.
- ! *
- ! * -b: Binary mode. Synonym for -i. MS-DOS only.
- ! *
- ! * -t: Text mode (defined only under MS-DOS). Treat file
- ! * as text (CR-LF and ^Z special) in melted form. Default
- ! * unless BIN_DEFAULT specified.
- *
- * -v: Write freezing statistics
- *
- ***************
- *** 185,191 ****
- filelist = fileptr = (char **)(malloc(argc * sizeof(*argv)));
- *filelist = NULL;
-
- ! if((cp = rindex(argv[0], PATH_SEP)) != 0) {
- cp++;
- } else {
- cp = argv[0];
- --- 196,202 ----
- filelist = fileptr = (char **)(malloc(argc * sizeof(*argv)));
- *filelist = NULL;
-
- ! if((cp = last_sep(argv[0])) != 0) {
- cp++;
- } else {
- cp = argv[0];
- ***************
- *** 192,198 ****
- }
-
- #ifdef MSDOS
- ! if(strcmp(cp, "MELT.EXE") == 0) {
- #else
- if(strcmp(cp, "melt") == 0) {
- #endif
- --- 203,210 ----
- }
-
- #ifdef MSDOS
- ! /* use case-insensitive match: parent may not be command.com */
- ! if(stricmp(cp, "melt.exe") == 0) {
- #else
- if(strcmp(cp, "melt") == 0) {
- #endif
- ***************
- *** 200,206 ****
- do_melt = 1;
-
- #ifdef MSDOS
- ! } else if(strcmp(cp, "FCAT.EXE") == 0) {
- #else
- } else if(strcmp(cp, "fcat") == 0) {
- #endif
- --- 212,219 ----
- do_melt = 1;
-
- #ifdef MSDOS
- ! /* use case-insensitive match: parent may not be command.com */
- ! } else if(stricmp(cp, "fcat.exe") == 0) {
- #else
- } else if(strcmp(cp, "fcat") == 0) {
- #endif
- ***************
- *** 253,260 ****
- break;
- #ifdef MSDOS
- case 'i':
- ! image = 1;
- break;
- #endif
-
- case 'v':
- --- 266,278 ----
- break;
- #ifdef MSDOS
- case 'i':
- ! case 'b':
- ! image = O_BINARY; /* binary (aka image) mode */
- break;
- +
- + case 't': /* text mode */
- + image = O_TEXT;
- + break;
- #endif
-
- case 'v':
- ***************
- *** 384,390 ****
- /* Open input file for freezing */
-
- #ifdef MSDOS
- ! if ((freopen(*fileptr, image == 2 ? "rt" : "rb", stdin))
- == NULL)
- #else
- if ((freopen(*fileptr, "r", stdin)) == NULL)
- --- 402,408 ----
- /* Open input file for freezing */
-
- #ifdef MSDOS
- ! if ((freopen(*fileptr, image == O_TEXT ? "rt" : "rb", stdin))
- == NULL)
- #else
- if ((freopen(*fileptr, "r", stdin)) == NULL)
- ***************
- *** 397,403 ****
- /* Generate output filename */
- strcpy(ofname, *fileptr);
- #ifndef BSD4_2 /* Short filenames */
- ! if ((cp = rindex(ofname, PATH_SEP)) != NULL) cp++;
- else cp = ofname;
- # ifdef MSDOS
- if (topipe == 0 && (sufp = rindex(cp, '.')) != NULL &&
- --- 415,421 ----
- /* Generate output filename */
- strcpy(ofname, *fileptr);
- #ifndef BSD4_2 /* Short filenames */
- ! if ((cp = last_sep(ofname)) != NULL) cp++;
- else cp = ofname;
- # ifdef MSDOS
- if (topipe == 0 && (sufp = rindex(cp, '.')) != NULL &&
- ***************
- *** 457,463 ****
- if (do_melt == 0 || debug == 0) {
- #endif
- #ifdef MSDOS
- ! if (freopen(ofname, do_melt && image == 2 ? "wt" : "wb",
- stdout) == NULL)
- #else
- if (freopen(ofname, "w", stdout) == NULL)
- --- 475,481 ----
- if (do_melt == 0 || debug == 0) {
- #endif
- #ifdef MSDOS
- ! if (freopen(ofname, do_melt && image == O_TEXT ? "wt" : "wb",
- stdout) == NULL)
- #else
- if (freopen(ofname, "w", stdout) == NULL)
- ***************
- *** 474,479 ****
- --- 492,506 ----
- indicator_count = 1024;
- }
- }
- + else { /* output is to stdout */
- + #ifdef MSDOS
- + /* freeze output always binary; melt output
- + is binary if image == O_BINARY
- + */
- + if (do_melt == 0 || image == O_BINARY)
- + setmode(fileno(stdout), O_BINARY);
- + #endif
- + }
- /* Actually do the freezing/melting */
- if (do_melt == 0)
- freeze();
- ***************
- *** 493,498 ****
- --- 520,531 ----
- Pipe:
- topipe = 1;
- if (do_melt == 0) {
- + #ifdef MSDOS
- + /* freeze output always binary */
- + /* freeze input controlled by -i -t -b switches */
- + setmode(fileno(stdout), O_BINARY);
- + setmode(fileno(stdin), image);
- + #endif
- #ifdef COMPAT
- new_flg = 1;
- #endif
- ***************
- *** 500,505 ****
- --- 533,544 ----
- if(!quiet)
- putc('\n', stderr);
- } else {
- + #ifdef MSDOS
- + /* melt input always binary */
- + /* melt output to stdout binary if so requested */
- + setmode(fileno(stdin), O_BINARY);
- + setmode(fileno(stdout), image);
- + #endif
- /* Check the magic number */
- if ((getchar() != magic_header[0])
- #ifdef COMPAT
- ***************
- *** 566,573 ****
-
- writeerr()
- {
- ! perror ( ofname );
- ! unlink ( ofname );
- exit ( 1 );
- }
-
- --- 605,614 ----
-
- writeerr()
- {
- ! if (!topipe) {
- ! perror ( ofname );
- ! unlink ( ofname );
- ! }
- exit ( 1 );
- }
-
- ***************
- *** 713,718 ****
- --- 754,763 ----
- Table[5], Table[6], Table[7], Table[8]);
- fprintf(stderr, "HUFFMAN: %ld (max frequency)\n", (long)MAX_FREQ);
- fprintf(stderr, "HASH: %d bits\n", BITS);
- + #ifdef MSDOS
- + fprintf(stderr, "Default melted mode: %s\n",
- + image == O_BINARY ? "binary" : "text");
- + #endif
- exit(0);
- }
-
- ***************
- *** 759,761 ****
- --- 804,826 ----
- fprintf(stderr, "Using \"%s%s\" type\n", type, t);
- }
- }
- +
- + #ifdef MSDOS
- + /* MSDOS typically has ':' and '\\' separators, but some command
- + processors (and the int 21h function handler) support '/' too.
- + Find the last of these.
- + */
- + char *
- + last_sep(s)
- + register char *s;
- + {
- + register char *c;
- +
- + char *p;
- + for (p = NULL; *s; s++)
- + if (*s == '/' || *s == '\\' || *s == ':')
- + p = s;
- + return(p);
- + }
- +
- + #endif /* MSDOS */
- *** ../distribution/freeze.h Mon May 13 15:12:08 1991
- --- freeze.h Sun Mar 31 12:25:52 1991
- ***************
- *** 4,12 ****
- #ifdef SUN4
- #include <sys/stdtypes.h>
- #else
- - #if !defined(ultrix) && defined(__GNUC__)
- - typedef int mode_t; /* for GCC */
- - #endif
- # ifndef getc
- # define getc(p) (--(p)->_cnt < 0 ? _filbuf(p) : (int) *(p)->_ptr++)
- # endif
- --- 4,9 ----
- ***************
- *** 36,41 ****
- --- 33,39 ----
-
- #ifdef MSDOS
- #include <stdlib.h>
- + #include <fcntl.h>
- #endif
-
- typedef unsigned char uchar;
- *** ../distribution/huf.c Wed Mar 27 19:44:46 1991
- --- huf.c Mon May 13 13:23:35 1991
- ***************
- *** 221,226 ****
- --- 221,228 ----
- if (putlen) {
- putchar((int)(putbuf >> 8));
- bytes_out++;
- + if (ferror(stdout))
- + writeerr();
- }
- }
-
- ***************
- *** 400,410 ****
- putchar((int)(i & 0xFF));
- putchar((int)((i >> 8) & 0x7F));
- putchar((int)(Table[6] & 0x3F));
- }
-
- read_header() {
- short i, j;
- ! i = getchar() | (getchar() << 8);
- Table[1] = i & 1; i >>= 1;
- Table[2] = i & 3; i >>= 2;
- Table[3] = i & 7; i >>= 3;
- --- 402,415 ----
- putchar((int)(i & 0xFF));
- putchar((int)((i >> 8) & 0x7F));
- putchar((int)(Table[6] & 0x3F));
- + if (ferror(stdout))
- + writeerr();
- }
-
- read_header() {
- short i, j;
- ! i = getchar() & 0xFF;
- ! i |= (getchar() & 0xFF) << 8;
- Table[1] = i & 1; i >>= 1;
- Table[2] = i & 3; i >>= 2;
- Table[3] = i & 7; i >>= 3;
- *** ../distribution/lz.h Mon May 13 15:12:10 1991
- --- lz.h Sun May 12 14:15:03 1991
- ***************
- *** 49,55 ****
- #else
- # if parts == 3
- extern u_short next0[], next1[], next2[];
- ! # else
- # if parts == 5
- extern u_short next0[], next1[], next2[], next3[], next4[];
- # else
- --- 49,55 ----
- #else
- # if parts == 3
- extern u_short next0[], next1[], next2[];
- ! # else
- # if parts == 5
- extern u_short next0[], next1[], next2[], next3[], next4[];
- # else
- ***************
- *** 71,77 ****
-
- #define InsertNode(r)\
- {\
- ! register hash_t p, first_son;\
- register uchar *key;\
- key = &text_buf[r];\
- p = N + 1 + (key[0] & MASK0) |\
- --- 71,77 ----
-
- #define InsertNode(r)\
- {\
- ! register hash_t p; register u_short first_son;\
- register uchar *key;\
- key = &text_buf[r];\
- p = N + 1 + (key[0] & MASK0) |\
- *** ../distribution/makefile Mon May 13 15:12:10 1991
- --- makefile Fri May 10 19:40:42 1991
- ***************
- *** 9,17 ****
-
- CC = gcc
-
- ! CFLAGS = -DBITS=18 -O -DCOMPAT #-DBSD42 -DSUN4
-
- ! LINTFLAGS = -DBITS=15 -DCOMPAT -DDEBUG -DGATHER_STAT
-
- MAKEFILE = makefile
-
- --- 9,17 ----
-
- CC = gcc
-
- ! CFLAGS = -DBITS=18 -O -DCOMPAT -fstrength-reduce #-DBSD42 -DSUN4
-
- ! LINTFLAGS = -DBITS=15 -DCOMPAT -DDEBUG -DGATHER_STAT -x
-
- MAKEFILE = makefile
-
- *** ../distribution/patchlevel.h Mon May 13 15:12:11 1991
- --- patchlevel.h Fri Mar 29 12:18:11 1991
- ***************
- *** 1 ****
- ! #define PATCHLEVEL 1
- --- 1 ----
- ! #define PATCHLEVEL 2
-
- --
- Leonid A. Broukhis | 89-1-95 Liberty St. | "BROUKHIS" is Hebrew for
- 7+095 494.6241 (h) | Moscow 123481 USSR | "BENEDICTAE"
- 7+095 132.9475 (o) | (leo@s514.ipmce.su) | {Licet omnia qualibet dicas}
-
-
- exit 0 # Just in case...
- --
- Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM
- Sterling Software, IMD UUCP: uunet!sparky!kent
- Phone: (402) 291-8300 FAX: (402) 291-4362
- Please send comp.sources.misc-related mail to kent@uunet.uu.net.
-